﻿@{
    ViewBag.Title = "EditNavBar";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@model NavBarModel
<div class="row-fluid" style="margin-top: 20px">
    <div class="span24 span-first">
        <form class="form-horizontal" method="post" action="/Admin/NavBar/EditNavBar">
            <div class="control-group">
                <label class="control-label">上级栏目：</label>
                <div class="controls">
                    <div id="ParentName" style="width: 350px">
                        @Html.HiddenFor(x => x.ParentID)
                    </div>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>栏目名称：</label>
                <div class="controls">
                    @Html.HiddenFor(x => x.ID)
                    @Html.TextBoxFor(x => x.NavName, new { style = "width:350px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>栏目类型：</label>
                <div class="controls">
                    @{
                        Object NavType10 = null;
                        Object NavType20 = null;
                        if (Model.NavType == "10")
                        {
                            NavType10 = new { @checked = true };
                        }
                        else
                        {
                            NavType20 = new { @checked = true };
                        }
                    }
                    <label>@Html.RadioButtonFor(x => x.NavType, 10, NavType10) 首页</label>
                    <label>@Html.RadioButtonFor(x => x.NavType, 20, NavType20) 链接地址</label>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">链接地址：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.NavUrl, new { style = "width:275px;margin-right:5px;" })<button class="button button-small" type="button" id="selectPageBtn">选择页面</button>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>打开方式：</label>
                <div class="controls">
                    @{
                        Object OpenType10 = null;
                        Object OpenType20 = null;
                        if (Model.OpenType == "10")
                        {
                            OpenType10 = new { @checked = true };
                        }
                        else
                        {
                            OpenType20 = new { @checked = true };
                        }
                    }
                    <label>@Html.RadioButtonFor(x => x.OpenType, 10, OpenType10) 本窗口</label>
                    <label>@Html.RadioButtonFor(x => x.OpenType, 20, OpenType20) 新窗口</label>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>是否显示：</label>
                <div class="controls">
                    @{
                        Object Status10 = null;
                        Object Status20 = null;
                        if (Model.Status == "10")
                        {
                            Status10 = new { @checked = true };
                        }
                        else
                        {
                            Status20 = new { @checked = true };
                        }
                    }
                    <label>@Html.RadioButtonFor(x => x.Status, 10, Status10) 显示</label>
                    <label>@Html.RadioButtonFor(x => x.Status, 20, Status20) 隐藏</label>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>排序：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Sort)
                </div>
            </div>
            <hr>
            <div style="text-align: center">
                <button class="button button-primary" type="submit">提交</button>
                <button class="button" type="reset" onclick="parent.CloseWin()">取消</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $("input[name=NavType]").click(function () {
        if ($(this).val() == "10") {
            $('#NavUrl').val("/");
            $('#NavUrl').attr('disabled', 'disabled');
            $('#selectPageBtn').attr('disabled', 'disabled');
        } else {
            $('#NavUrl').val("");
            $('#NavUrl').removeAttr('disabled');
            $('#selectPageBtn').removeAttr('disabled');
        }
    })
    if ('@Model.NavType' == '10') {
        $('#NavUrl').val("/");
        $('#NavUrl').attr('disabled', 'disabled');
        $('#selectPageBtn').attr('disabled', 'disabled');
    }
    BUI.use(['bui/extensions/treepicker', 'bui/tree'], function (TreePicker, Tree) {
        var Select = BUI.Select;
        var data = eval('@Html.Raw(Model.ParentNavList)');
        var tree = new Tree.TreeList({
            nodes: data,
            showLine: true
        });
        var picker = new TreePicker({
            width: '360',
            children: [tree]
        });
        select = new Select.Select({
            render: '#ParentName',
            width: '360',
            picker: picker,
            forceFit: false,
            valueField: '#ParentID'
        });
        select.render();
    });
</script>
